// packageF/debt/debtindex/debtindex.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        settingInfo:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        wx.setNavigationBarTitle({
          title: '置换亿栈',
        })
    },
    tourl(e){
        console.log(e)
        let key = e.currentTarget.dataset.key;
        // 债务人 2
        if(key == 'is_debtor'){
            if(this.data.settingInfo.is_debtor == 1 || this.data.settingInfo.isset_debtor == 1){
                wx.navigateTo({
                  url: '/packageF/debt/debtor/debtorindex/debtorindex',
                })
            }else{
                wx.navigateTo({
                  url: '/packageF/debt/debtapply/debtapply?type=2',
                })
            }
        }
        // 债权人 1
        if(key == 'is_owner'){
            if(this.data.settingInfo.is_owner == 1 || this.data.settingInfo.isset_owner == 1){
                wx.navigateTo({
                  url: '/packageF/debt/creditor/creditorindex',
                })
            }else{
                wx.navigateTo({
                  url: '/packageF/debt/debtapply/debtapply?type=1',
                })
            }
        }

        // vip
        if(key == 'is_vip'){
            if(this.data.settingInfo.is_debtor == 1 || this.data.settingInfo.is_debtor.is_owner == 1){
                app.tips('您无法申请成为VIP');
                return
            }
            if(this.data.settingInfo.is_vip == 1 || this.data.settingInfo.isset_vip == 1){
                wx.navigateTo({
                  url: '/packageF/debt/vipIndex/vipIndex',
                })
            }else{
                if(this.data.settingInfo.vip_applying == 1){
                    app.tips('vip待审核中');
                    return
                }
                wx.navigateTo({
                  url: '/packageF/debt/debtapply/debtapply?type=3',
                })
            }
        }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
      this.getData();
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },
    getData() {
        let urlStr = app.getNetAddresss('plugin.debt-shop.frontend.debt-member.applyData');
        app._getNetWork({
            url: urlStr,
            success: (resdata) => {
                var res = resdata.data;
                if (res.result == 1) {
                    this.setData({
                        settingInfo: res.data
                    })
                } else {
                    wx.showToast({
                        icon: 'none',
                        title: res.msg,
                        duration: 1500
                    });
                }
            },
            fail: function (res) {
                console.log(res);
            }
        });
    }
})